package com.dc.controller;

import com.dc.baseController.BaseController;
import com.dc.utils.StringUtil;
import com.dc.utils.sendsms;
import com.wordnik.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

@RequestMapping("/Send")
@Controller
public class SendController{
    @RequestMapping("/sendCode")
    public void sendCode(HttpServletRequest req, PrintWriter pw) throws ServletException, IOException {
        String phone = req.getParameter("phone");
        System.out.println(phone);
        String strCode = sendsms.SMS(phone);
        req.getSession().setAttribute("code", strCode);
        System.out.println(strCode);
        HttpSession session = req.getSession();
        session.setAttribute("Strcode", strCode);
        if (strCode != "") {
            pw.write(strCode);
        }
    }
}
